package app_res

import (
	myapp_dao "hft/Http/Services/front/app/app_dao"
	"hft/Http/Services/front/pc/app_dao"
	"hft/Http/Services/front/pc/app_model"
	"hft/global"
)

type Index struct{}

// 获取PC端首页
func (*Index) GetIndex(city int) (data *app_model.Index, err error) {
	regionLink, err := myapp_dao.AppBaseDao.GetRegion(global.OC_DB, city)
	var OpenLou = app_dao.PCIndexDao.GetOpenTime(global.OC_DB, regionLink)
	var NewLou = app_dao.PCIndexDao.GetLou(global.OC_DB, regionLink)
	var HotLou = app_dao.PCIndexDao.GetTeSeLou(global.OC_DB, "热门楼盘", regionLink, false, false)
	var GangXuLou = app_dao.PCIndexDao.GetTeSeLou(global.OC_DB, "刚需好房", regionLink, false, false)
	var Recommend = app_dao.PCIndexDao.GetTeSeLou(global.OC_DB, "力荐新房", regionLink, true, true)
	var HotGuide = app_dao.PCIndexDao.GetArt(global.OC_DB, regionLink, []int{1}, false)
	var Act = app_dao.PCIndexDao.GetAct(global.OC_DB, regionLink)
	var news = app_dao.PCIndexDao.GetArt(global.OC_DB, regionLink, []int{3, 5}, true)
	var renQi = app_dao.PCIndexDao.GetTeSeLou(global.OC_DB, "人气楼盘", regionLink, false, false)
	var youhui = app_dao.PCIndexDao.GetTeSeLou(global.OC_DB, "优惠楼盘", regionLink, false, false)
	var goufang = app_dao.PCIndexDao.GetArt(global.OC_DB, regionLink, []int{5}, false)
	var Index = &app_model.Index{
		Lou: app_model.IndexLou{
			OpenTimeLou:  OpenLou,
			NewestLou:    NewLou,
			HotLou:       HotLou,
			GangXuLou:    GangXuLou,
			RecommendLou: Recommend,
			RenQiLou:     renQi,
			YouHuiLou:    youhui,
		},
		Article: app_model.ArticleList{
			HotGuide: HotGuide,
			HotNew:   news,
			GouFang:  goufang,
		},
		Active: Act,
	}
	return Index, nil
}

var IndexService = new(Index)
